package com.hbnu.test.www.net;

import java.io.*;
import java.net.Socket;

public class TCP_client03_reverse {
    public static void main(String[] args) {
        try (Socket socket = new Socket("127.0.0.1", 6666);
        ) {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
            BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String line = null;
            while((line = bufferedReader.readLine())!=null){
                if("over".equalsIgnoreCase(line)){
                    break;
                }
                out.write(line);//发送消息
                out.newLine();
                out.flush();
                String result = in.readLine();
                System.out.println("返回结果:" + result);

            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
